Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

483
Visualizações
(moduleNameMapper not applied) Vue jest configuration error: "Could not locate module @/javascript/app.vue mapped as:"

I have a Vue2 Rails application and tried to install Jest which worked. The problem is that I cannot test my components because of this error:

  ● Test suite failed to run

    Configuration error:
    
    Could not locate module @/app.vue mapped as:
    /Users/name/project/project-name/src/app.vue.
    
    Please check your configuration for these entries:
    {
      "moduleNameMapper": {
        "/^@\/(.*)$/": "/Users/name/project/project-name/src/$1"
      },
      "resolver": null
    }

Which makes sense, because my component is in /Users/name/project/project-name/app/javascript/app.vue and there is no src directory in my project, because it is a Rails app.

But in my package.json I added

"jest": {
    "moduleNameMapper": {
      "^@/(.*)$": "<rootDir>/app/javascript/$1"
    },
    "preset": "@vue/cli-plugin-unit-jest/presets/no-babel"
  }

Which obviously does not work. Putting all of it into a src folder also does not work. I feel like I'm missing some crucial configuration.

Edit: Alright, I went in and changed my moduleNameMapper by hand which is definitely not how this should be done, but I couldn't get it to work otherwise. In node_modules/jest-resolve/build/index.js at line 121 I wrote

this._options.moduleNameMapper[0].moduleName = "/Users/name/project/project-name/app/javascript/$1";

I don't have time to figure out the real issue right now. I will come back when I have the real solution.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda